package br.net.atasacramental.trimestre.dao;
import br.net.atasacramental.trimestre.model.Trimestre;
import br.net.atasacramental.util.ConexaoDB;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
/**
* @author alexandre.araujo
*/
public class TrimestreDAO{
	private String[][] ordemP = {{"idTrimestre", "desc"}};
	@SuppressWarnings("unchecked")
	public List<Trimestre> get() {
		return (List<Trimestre>) ConexaoDB.get(Trimestre.class,true,1,100,null,ordemP);
	}
	public Trimestre getByIdTrimestre(int idTrimestre){
		return (Trimestre) ConexaoDB.getById(Trimestre.class,idTrimestre);
	}
	@SuppressWarnings("unchecked")
	public List<Trimestre> getByAno(int ano){		
		Map<String,Object> params = new HashMap<String, Object>();
		params.put("ano", ano);
		return (List<Trimestre>) ConexaoDB.get(Trimestre.class,true,1,100,params,ordemP);
	}
	@SuppressWarnings("unchecked")
	public List<Trimestre> getByNrTrimestre(int nrTrimestre){		
		Map<String,Object> params = new HashMap<String, Object>();
		params.put("nrTrimestre", nrTrimestre);
		return (List<Trimestre>) ConexaoDB.get(Trimestre.class,true,1,100,params,ordemP);
	}
	@SuppressWarnings("unchecked")
	public List<Trimestre> getBySnAberto(String snAberto){		
		Map<String,Object> params = new HashMap<String, Object>();
		params.put("snAberto", snAberto);
		return (List<Trimestre>) ConexaoDB.get(Trimestre.class,true,1,100,params,ordemP);
	}

	public boolean insert(Trimestre t){
		return ConexaoDB.insert(t);
	}
	public boolean update(Trimestre t){
		return ConexaoDB.update(t);
	}
	public boolean delete(Trimestre t){
		return ConexaoDB.delete(t);
	}
}